// 迭代器的使用 iterator
// let obj={
//   'name':'前端小鹿',
//   'age':'18',
//   'sex':'男'
// }

let arr = [2, 4, 5, 7, 1]

function myIterator(param) {
  let argument = param
  let index = -1
    return {
      next: function () {
        index++
        return index < argument.length ? { value: argument[index], done: false } : { value: undefined, done: true }
      }
    }
}

let test = myIterator(arr)
console.log(test.next())
console.log(test.next())
console.log(test.next())
console.log(test.next())
console.log(test.next())
console.log(test.next())